package com.wtwd.campus.utils;

import com.wtwd.campus.annotation.AuditLog;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map;

public class AuditLogUtils {
    public static void modifyAnnotation(Method method, String content,String orgCode) {
        AuditLog auditLog = method.getAnnotation(AuditLog.class);
        InvocationHandler invocationHandler = Proxy.getInvocationHandler(auditLog);
        Field fileld = null;
        try {
            fileld = invocationHandler.getClass().getDeclaredField("memberValues");
            fileld.setAccessible(true);
            Map<String,Object> values = (Map<String,Object>)fileld.get(invocationHandler);
            values.put("operationContent",content);
            values.put("orgCode",orgCode);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }

    }
}
